package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.OceanPreStoragePosition;
import com.egao.orderB.service.OceanPreStoragePositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 *
 * 预存仓位
 * @author : Doman
 * @date : 2021-10-19 16:47:57
 * @version ：1.0
 */

@Api(tags = "预存仓位")
@RestController
@RequestMapping("/api/orderB/oceanPreStoragePosition")
public class OceanPreStoragePositionController extends BaseController {

	@Autowired
	private OceanPreStoragePositionService oceanPreStoragePositionService;

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:list')")
  @ApiOperation(value ="分页查询预存仓位",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "bookingAgentId:订舱代理id\n" +
    "bookingAgent:订舱代理\n" +
    "billOfLading:提单号\n" +
    "ship:船公司\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "airRoute:航线\n" +
    "goShipDay:开船日\n" +
    "boxType:箱型\n" +
    "price:金额\n" +
    "deposit:押金\n" +
          "depositPath:押金路径 对公，对私，蔡总\n" +
    "createTime:创建时间\n" +
    "createUser:创建人\n" +
    "updateTime:更新时间\n" +
    "updateUser:更新人\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/list")
  public JsonResult page(PageResult2<T> page, OceanPreStoragePosition oceanPreStoragePosition) throws Exception{
    return oceanPreStoragePositionService.list(page, oceanPreStoragePosition, getLoginUser());
  }

	/**
	 * 分页查询取消列表
	 */
	@PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:list')")
  @ApiOperation(value ="分页查询取消预存仓位",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "bookingAgentId:订舱代理id\n" +
    "bookingAgent:订舱代理\n" +
          "billOfLading:提单号\n" +
    "ship:船公司\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
          "airRoute:航线\n" +
    "goShipDay:开船日\n" +
    "boxType:箱型\n" +
    "price:金额\n" +
    "deposit:押金\n" +
          "depositPath:押金路径 对公，对私，蔡总\n" +
    "createTime:创建时间\n" +
    "createUser:创建人\n" +
    "updateTime:更新时间\n" +
    "updateUser:更新人\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/cancelList")
  public JsonResult cancelList(PageResult2<T> page, OceanPreStoragePosition oceanPreStoragePosition) throws Exception{
    oceanPreStoragePosition.setDeleted(2);
    return oceanPreStoragePositionService.list(page, oceanPreStoragePosition, getLoginUser());
  }

  @PostMapping("/listOpen")
  @ApiOperation(value = "预存仓位展开查询",notes = "" +
          "id:预存仓位id\n" +
          "\n",httpMethod = "POST")
  public JsonResult listOpen(OceanPreStoragePosition oceanPreStoragePosition, HttpServletRequest request) {
    return oceanPreStoragePositionService.listOpen(oceanPreStoragePosition, getLoginUser());
  }

  /**
   * 查询全部预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:list')")
  @ApiOperation("查询全部预存仓位")
  @PostMapping("/listAll")
  public JsonResult list(OceanPreStoragePosition oceanPreStoragePosition){
    return oceanPreStoragePositionService.list(oceanPreStoragePosition, getLoginUser());
  }

  /**
   * 查询全部预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:list')")
  @ApiOperation("饼图 箱型数量")
  @PostMapping("/boxTypeNum")
  public JsonResult boxTypeNum(OceanPreStoragePosition oceanPreStoragePosition){
    return oceanPreStoragePositionService.boxTypeNum(oceanPreStoragePosition, getLoginUser());
  }

  /**
   * 根据id查询预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:list')")
  @ApiOperation("根据id查询预存仓位")
  @PostMapping("/get")
  public JsonResult get(OceanPreStoragePosition oceanPreStoragePosition) {
    return oceanPreStoragePositionService.getById(oceanPreStoragePosition);
  }


  /**
   * 添加预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:save')")
  @OperLog(value = "预存仓位", desc = "添加", param = false, result = true)
  @ApiOperation(value ="添加预存仓位",notes = "" +
    "bookingAgentId:订舱代理id\n" +
    "bookingAgent:订舱代理\n" +
          "billOfLading:提单号\n" +
    "ship:船公司\n" +
          "vessel:船名\n" +
          "voyage:航次\n" +
          "airRoute:航线\n" +
          "goShipDay:开船日\n" +
    "boxType:箱型\n" +
    "price:金额\n" +
    "deposit:押金\n" +
          "depositPath:押金路径 对公，对私，蔡总\n" +
    "",httpMethod = "POST")
  @PostMapping("/save")
  public JsonResult save(Model model, OceanPreStoragePosition oceanPreStoragePosition) {
    return oceanPreStoragePositionService.save(oceanPreStoragePosition, getLoginUser());
  }

  /**
   * 修改预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:update')")
  @OperLog(value = "预存仓位", desc = "修改", param = false, result = true)
  @ApiOperation(value ="修改预存仓位",notes = "" +
    "id:id\n" +
    "bookingAgentId:订舱代理id\n" +
    "bookingAgent:订舱代理\n" +
    "billOfLading:提单号\n" +
    "ship:船公司\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "airRoute:航线\n" +
    "goShipDay:开船日\n" +
    "boxType:箱型\n" +
    "price:金额\n" +
    "deposit:押金\n" +
    "depositPath:押金路径 对公，对私，蔡总\n" +
    "",httpMethod = "POST")
  @PostMapping("/update")
  public JsonResult update(Model model, OceanPreStoragePosition oceanPreStoragePosition) {
    return oceanPreStoragePositionService.update(oceanPreStoragePosition, getLoginUser());
  }

  /**
   * 取消预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:update')")
  @OperLog(value = "取消预存仓位", desc = "修改", param = false, result = true)
  @ApiOperation(value ="取消预存仓位",notes = "" +
    "id:id\n" +
    "",httpMethod = "POST")
  @PostMapping("/cancel")
  public JsonResult cancel(Model model, OceanPreStoragePosition oceanPreStoragePosition) {
    return oceanPreStoragePositionService.cancel(oceanPreStoragePosition, getLoginUser());
  }

  /**
   * 删除预存仓位
   */
  @PreAuthorize("hasAuthority('orderB:oceanPreStoragePosition:remove')")
  @OperLog(value = "预存仓位", desc = "删除", result = true)
  @ApiOperation(value ="删除预存仓位",notes = "" +
          "id:id\n" +
          "",httpMethod = "POST")
  @PostMapping("/remove")
  public JsonResult remove(OceanPreStoragePosition oceanPreStoragePosition ) {
    return oceanPreStoragePositionService.remove(oceanPreStoragePosition, getLoginUser());
  }

}
